import { NestFactory, HttpAdapterHost } from '@nestjs/core';
// import { Logger } from '@nestjs/common';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { AllExceptionFilter } from './filters';
import { AppModule } from './app.module';

// declare const module: any;

async function bootstrap() {
  // const logger = new Logger();
  const app = await NestFactory.create(AppModule, {
    // logger: false,
  });
  const logger = app.get(WINSTON_MODULE_NEST_PROVIDER);
  app.useLogger(logger);
  // console.log('logger--', logger, logger.logger);
  const httpAdapter = app.get(HttpAdapterHost);
  app.useGlobalFilters(new AllExceptionFilter(logger, httpAdapter));
  app.setGlobalPrefix('api/v1');
  await app.listen(process.env.PORT ?? 3000);

  // logger.log('App运行在: 3000');
  // logger.warn('App运行在: 3000');
  // logger.error('App运行在: 3000');

  /* if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => app.close());
  } */
}
bootstrap();
